(async function () {
    let business = cookie.get('business') ? cookie.get('business') : {}

    if (JSON.stringify(business) == '{}') {
        mui.toast('未登陆，请先去登陆')
        setTimeout(() => {
            location.href = "login.html"
        }, 1000)

        return false;
    }

    business = JSON.parse(business)

    let data = {
        id: business.id,
        mobile: business.mobile
    }

    let result = await POST({ url: 'business/check', params: data })

    if(result.code == 0)
    {
        cookie.clear();
        setTimeout(() => {
            location.href = "login.html"
        }, 1000)

        return false;
    }

    // 存储用户数据
    cookie.set('business', JSON.stringify(result.data))
})()

function getParam(name)
{
    let query = decodeURI(location.search.slice(1));

    if(query)
    {
        let vars = query.split('&');

        if(vars.length > 0)
        {
            for(let val of vars)
            {
                let pair = val.split('=');

                if(pair.length > 0)
                {
                    if(pair[0] == name)
                    {
                        return pair[1];
                    }
                }
                
            }
        }
        
    }

    return null;
    
}


